#!/usr/bin/env python
# -*- coding:utf-8 -*-
# @Time: 2022/9/16 16:36
# @Author: 刘航
# @Email: xxx@gmail.com
# @File：customer_pool_page.py

from selenium.webdriver.common.by import By
from pages.base_page import BasePage
from selenium.webdriver.support.select import Select
class CustomerPoolPage(BasePage):
    first_row_locator = (By.XPATH,'/html/body/div[5]/div[2]/div[2]/form/table/tbody/tr[1]')
    first_column_locator =(By.TAG_NAME,"td")
    first_cust_locator = (By.CSS_SELECTOR,".table > tbody:nth-child(3) > tr:nth-child(1) > td:nth-child(2) > a:nth-child(1)")
    receive_locator=(By.CSS_SELECTOR,".table > tbody:nth-child(3) > tr:nth-child(1) > td:nth-child(9) > a:nth-child(4)")
    view_receive_locator = (By.CSS_SELECTOR,".alert")
    select_industry_locator = (By.CSS_SELECTOR,"#field")
    search_locator = (By.CSS_SELECTOR,"#search")
    dosearch_locator = (By.ID,"dosearch")
    def first_row_data(self):
        """获取第一行数据"""
        element = self.driver.find_element(*self.first_row_locator)
        data = element.find_element(*self.first_column_locator)
        return data
    def first_cust_data(self):
        """列表第一位客户"""
        data = self.driver.find_element(*self.first_cust_locator).text
        return data
    def receive_cust(self):
        """客户池客户领取按钮"""
        self.driver.find_element(*self.receive_locator).click()
    def view_receive_status(self):
        """查看领取状态"""
        data = self.driver.find_element(*self.view_receive_locator).text
        return data
    def select_industry(self,select_industry):
        """操作搜索下拉框"""
        select_selenium = self.driver.find_element(*self.select_industry_locator)
        Select(select_selenium).select_by_visible_text(select_industry)

    def search_cust_industry(self,industry):
        """操作搜索框"""
        self.driver.find_element(*self.search_locator).send_keys(industry)
    def dosearch_cust(self):
        """点击搜索"""
        self.driver.find_element(*self.dosearch_locator).click()

